{extends file="../acp.html"}

{block name="title"}{$head_title}{/block}
{block name="content"}
<script>
    function no_pic(obj) {
        obj.setAttribute("src", "/Public/Images/acp/nopicture.jpg");
    }
</script>

<div class="tablesWrap">
    <div class="tables-searchbox">
        <form method="post">
            <span class="tbs-txt">帖子名称：</span>
            <input type="text" name="cf_post_name" value="{$cf_post_name}">

            <span class="tbs-txt">发帖人：</span>
            <input type="text" name="nick_name" value="{$nick_name}">

            <select name="cf_channel_id">
                <option value="">-所属频道-</option>
                {foreach from=$channel_list item=v}
                <option value="{$v.channel_id}" {if $cf_channel_id == $v.channel_id}selected{/if}>{$v.channel_name}</option>
                {/foreach}
            </select>

            <button type="submit" class="btn"><i class="gicon-search"></i>搜索</button>
        </form>
    </div>
    <!-- end tables-searchbox -->
    <table class="wxtables">
        <colgroup>
            <!-- <col width="7%"> -->
            <col width="5%">
            <col width="5%">
            <col width="7%">
            <col width="5%">
            <col width="5%">
            <col width="5%">
            {if $opt == success} <col width="7%">{/if}
            {if $opt == failure} <col width="7%">{/if}
            <col width="15%">
            <col width="15%">
        </colgroup>
        <thead>
        <tr>
            <!-- <td>选择</td> -->
            <td>帖子名称</td>
            <td>所属频道</td>
            <td>发布人</td>
            <td>目标金额</td>
            <td>已筹金额</td>
            <td>支持人数</td>
            {if $opt == success}<td>是否回帖</td>{/if}
            {if $opt == failure}<td>是否退款</td>{/if}
            <td>时间</td>
            <td>操作</td>
        </tr>
        </thead>
        <tbody>
        {foreach from=$cf_list  item=v }
        <tr>
            <!-- <td><input type="checkbox" class="checkbox" value="{$incubator.incubator_id}" name="checkIds[]"></td> -->
            <td>{$v.title}</td>
            <td>{$v.channel_name}</td>
            <td>{$v.nickname}</td>
            <td>{$v.goal_money}</td>
            <td>{$v.now_money}</td>
            <td>{$v.support_num}</td>
            {if $opt == success}<td>{if $v.is_ht}是{else}否{/if}</td>{/if}
            {if $opt == failure}<td>{if $v.is_refund}是{else}否{/if}</td>{/if}
            <td>添加时间：{if $v.addtime}{$v.acp_time}{else}{/if}<br/>
                审核时间：{if $v.pass_time}{$v.acp_pass_time}{else}{/if}<br/>
                结束时间：{if $v.end_time}{$v.acp_end_time}{else}{/if}
            </td>
            <td>
                {include file="./cf_opt.html"}
            </td>
        </tr>
        {foreachelse}
        <tr><td colspan="10">没有找到任何记录</td></tr>
        {/foreach}
        </tbody>
    </table>
    <!-- end wxtables -->
    <div class="tables-btmctrl clearfix">
        <!-- <div class="fl">
            <a href="javascript:selall()" class="btn btn-blue">全选</a>
            <a href="javascript:clearall()" class="btn btn-blue">取消</a>
            <a href="javascript:;" class="btn btn-blue J_batch_store">下架</a>
            <a href="javascript:;" class="btn btn-blue" onclick="delIncubatorBatch()">删除</a>
        </div> -->
        <div class="fr">
            <div class="paginate">
                {$show}
            </div>
            <!-- end paginate -->
        </div>
    </div>
    <!-- end tables-btmctrl -->
</div>
<!-- end tablesWrap -->
{/block}

{block name="js"}
<script src="/Public/Plugins/My97DatePicker/WdatePicker.js?version={$version}"></script>
<script src="__JS__/front/jquery.showLoading.min.js?version={$version}"></script>
<script src="__JS__/clipboard.min.js"></script>
<link rel="stylesheet" href="__CSS__/front/showLoading.css?version={$version}">
{literal}
<script>

    function post_link(post_id)
    {
//        var link = 'http://' + document.domain + '/FrontChannel/post_detail/post_id/' + post_id;
        var link = '/FrontChannel/post_detail/post_id/' + post_id;
        $.jPops.custom({
            title:"请复制链接",
            content:'<div>帖子的链接：' + link + '</div>',
            okBtnTxt:"复制",
            cancelBtnTxt:"关闭",
            callback:function(r)
            {
                if(r)
                {
                    text = link;
                    copy_text('jpops-btn-ok');
                }
                else
                {
                    return true;
                }
            }
        });
    }
    function copy_text(id)
    {
        var clipboard = new Clipboard('#' + id, {
            text: function() {
                return text;
            }
        });

        clipboard.on('success', function(e) {
            console.log(e);
            alert('复制成功');
        });

        clipboard.on('error', function(e) {
            console.log(e);
            alert('复制失败，请手动复制');
        });
    }

    <!--wangtao 2017.9.15 -start-->
    function set_featured(post_id)
    {
        var html = "确认将这个帖子设置成精选吗?";
        $.jPops.custom({
            title:"设置精选帖子",
            content:html,
            okBtnTxt:"确定",
            cancelBtnTxt:"取消",
            callback:function(r)
            {
                if(r)
                {
                    $.post('/AcpPost/set_featured',{'post_id':post_id},function(data) {
                        console.log(data)
                        if (data == 'success') {
                            alert('设置成功');
                            location.reload();
                        } else {
                            alert('设置失败，有另一个帖子被设置成精选贴，请稍后再试');
                        }
                    });
                }
                return true;
            }
        });
    }

    function del_featured(post_id)
    {
        var html = "确认将这个帖子删除精选吗?";
        $.jPops.custom({
            title:"删除精选帖子",
            content:html,
            okBtnTxt:"确定",
            cancelBtnTxt:"取消",
            callback:function(r)
            {
                if(r)
                {
                    $.post('/AcpPost/del_featured',{'post_id':post_id},function(data) {
                        console.log(data)
                        if (data == 'success') {
                            alert('删除精选成功');
                            location.reload();
                        } else {
                            alert('删除精选失败，请稍后再试');
                        }
                    });
                }
                return true;
            }
        });
    }

    <!--wangtao 2017.9.15 -end-->
    function set_status(cf_id,state)
    {
        var state_name = '';
        if(state == 1){
            state_name = '通过';
        }
        if(state == 2){
            state_name = '拒绝';
        }

        var html = '确认'+ state_name +'审核吗?';
        $.jPops.custom({
            title:"审核",
            content:html,
            okBtnTxt:"确定",
            cancelBtnTxt:"取消",
            callback:function(r)
            {
                if(r)
                {
                    $.post('/AcpPost/set_status',{'cf_id':cf_id,'state':state},function(data) {
                        console.log(data)
                        if (data.code == 1) {
                            alert(data.msg);
                            location.reload();
                        } else {
                            alert(data.msg);
                        }
                    });
                }
                return true;
            }
        });
    }


    function cf_refund(cf_id) {
        var html = '确认全额退款给用户吗?';
        $.jPops.custom({
            title:"退款",
            content:html,
            okBtnTxt:"确定",
            cancelBtnTxt:"取消",
            callback:function(r)
            {
                if(r)
                {
                    $.post('/AcpPost/failure_cf_refund',{'cf_id':cf_id},function(data) {
                        console.log(data)
                        if (data.code == 0) {
                            alert(data.msg);
                            location.reload();
                        } else {
                            alert(data.msg);
                        }
                    });
                }
                return true;
            }
        });
    }

    function del_post(post_id)
    {
        var html = "确认删除这个帖子吗?";
        $.jPops.custom({
            title:"删除帖子",
            content:html,
            okBtnTxt:"确定",
            cancelBtnTxt:"取消",
            callback:function(r)
            {
                if(r)
                {
                    $.post('/AcpPost/del_post',{'post_id':post_id},function(data) {
                        console.log(data)
                        if (data == 'success') {
                            alert('删除成功');
                            location.reload();
                        } else {
                            alert('删除失败，请稍后再试');
                        }
                    });
                }
                return true;
            }
        });
    }

    function recover_post(post_id)
    {
        var html = "确认恢复这个帖子吗?";
        $.jPops.custom({
            title:"恢复帖子",
            content:html,
            okBtnTxt:"确定",
            cancelBtnTxt:"取消",
            callback:function(r)
            {
                if(r)
                {
                    $.post('/AcpPost/recover_post',{'post_id':post_id},function(data) {
                        console.log(data)
                        if (data == 'success') {
                            alert('恢复成功');
                            location.reload();
                        } else {
                            alert('恢复失败，请稍后再试');
                        }
                    });
                }
                return true;
            }
        });
    }


</script>
{/literal}
{/block}
